//
//  UIImage+Utility.m
//  QQing
//
//  Created by 李杰 on 4/20/15.
//
//

#import "UIImage+Utility.h"

@implementation UIImage (Utility)

+ (UIImage *)imageWithColor:(UIColor *)color {
    CGRect rect          = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    //开始作画
    UIGraphicsBeginImageContext(rect.size);
    //一实例化一个的Quartz 2D绘画环境context，context相当于一个画布,可以在上面任意绘画
    CGContextRef context = UIGraphicsGetCurrentContext();
    //画布填充颜色
    CGContextSetFillColorWithColor(context, [color CGColor]);
    //画布填充框
    CGContextFillRect(context, rect);
    //当前画板生成图片
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    //结束作画
    UIGraphicsEndImageContext();
    
    return image;
}

@end
